package cn.hrlly.tao2shou.biz;

import android.content.Context;

import java.util.ArrayList;

import cn.hrlly.tao2shou.domain.Commodities;
import cn.hrlly.tao2shou.listener.OnShowHistoryCommoditiesListener;
import cn.hrlly.tao2shou.utils.DatabaseUtil;

/**
 * User: gengliang
 * Date: 2016-02-02
 * Time: 22:13
 */

public class ShowHistoryCommoditiesBizImpl implements ShowHistoryCommoditiesBiz{

    private OnShowHistoryCommoditiesListener onShowHistoryCommoditiesListener;
    private DatabaseUtil databaseUtil;

    public ShowHistoryCommoditiesBizImpl(OnShowHistoryCommoditiesListener onShowHistoryCommoditiesListener,Context context) {
        this.onShowHistoryCommoditiesListener = onShowHistoryCommoditiesListener;
        this.databaseUtil=new DatabaseUtil(context);
    }

    @Override
    public void showHistoryCommodities() {
        ArrayList<Commodities> arrayList=new ArrayList<>();
        arrayList= (ArrayList<Commodities>) databaseUtil.selectHistory();
        if(arrayList!=null)
            onShowHistoryCommoditiesListener.showHistoryCommoditiesSucc(arrayList);
    }

    @Override
    public void closeDataBase() {
        databaseUtil.closeDatabase();
    }
}
